Skip to main content

CNC Example 08: Use of Additional Axes

See the CNC08_AdditionalAxes.project sample project in the installation directory of CODESYS under ..\CODESYS SoftMotion\Examples.

This example extends the CNC01_direct.projekt project which is described in CNC Example 01: Generating OutQueue Directly. It demonstrates how to use additional axes. As in CNC Example 01, four positions are approached in the X/Y-plane with a defined velocity and acceleration. Furthermore, the additional axis A is run during each movement. The program sets two path switch points on the path.

Editing a CNC program in the editor

  1. Open the CNC01_direct.project project from the installation directory of CODESYS.

  2. In the project, open the CNC program Example.

  3. Add positions for the additional axis A to the travel commands:

    Example 49. CNC editor
    N0  G01 X82.9 Y 8.9 A20 F50 E30 E-30
    N10 G02 X84.9 Y84.6 A40 R100 H12 L10
    N20 G01 X 6.6 Y25.7 A60 H-1 O0.8
    N30 G03 X54.6 Y49.7 A80 R100


    sm_img_cnc_example8_1.png

Creating a drive interface and PLC configuration

  1. Insert an additional virtual drive A_Drive below the SoftMotion general axis pool.

  2. Set the parameters as follows:

    sm_img_cnc_example8_2.png

Editing an IEC program

  1. Open the CFC program Ipo.

  2. Activate the previously added drive A_Drive with the MC_Power function block.

    sm_img_cnc_example8_3.png
  3. In this example, a simple orientation axis (A_Drive) should be controlled with the additional axis A. For this reason, no more transformation modules are necessary. The set position of the interpolator corresponds directly to the set position of the drive and is applied via the SMC_POSINFO selector with the SMC_ControlAxisByPos function block. The application does not guarantee that the outputs of the interpolator are continuous. For example, the position of the additional axis ends at a different point than it begins. Therefore, you should activate the gap avoidance (bAvoidGaps, fGapVelocity, fGapAcceleration, and fGapDeceleration). Then connect the bStopIpo output to the bEmergency_Stop input of the interpolator and connect interpolator output iStatus to the respective inputs of the axis control function blocks.

    Above all, pay attention to the correct order of function blocks when programming with CFC.

    sm_img_cnc_example8_4.png

Commissioning

Compile and start the created program. The program executes the CNC motion as soon as the Execute input of the interpolator has been set. After the program has run completely, you can apply a new rising edge to restart it.

During the execution of the CNC program, note the position of the additional axis A (piSetPosition.dA) which is shown in the visualization of the interpolation POU.